#include "UCamera.h"

TCamera::TCamera() {
	position = TVector(0, 0, 0);
	lookat   = TVector(0, 0, 1);
	up       = TVector(0, 1, 0);
}

TCamera::TCamera(const TVector& position, const TVector& lookat, const TVector& up) {
	set(position, lookat, up);
}

void TCamera::set(const TVector& position, const TVector& lookat, const TVector& up) {
	this->position = position;
	this->lookat   = lookat;
	this->up       = up;
	this->lookat  -= this->position;
	this->lookat.Normalize();
	this->up.Normalize();
}

void TCamera::rotate(const TVector& r) {

}

void TCamera::translate(const TVector& t) {
	position += t;
}

TVector TCamera::getPosition() {
	return position;
}

TVector TCamera::getLookat() {
	return lookat;
}

TVector TCamera::getUp() {
	return up;
}

void TCamera::apply() const {
	gluLookAt(position.x, position.y, position.z, position.x + lookat.x, position.y + lookat.y, position.z + lookat.z, 0, 1, 0); //Eye, centre, up
}
